aboutsummaryrefslogtreecommitdiff
path: root/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx')
-rw-r--r--src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
new file mode 100644
index 0000000..6e2495b
--- /dev/null
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
@@ -0,0 +1,31 @@
+import { IconLabel } from '@umami/react-zen';
+import { useCallback } from 'react';
+import { TypeIcon } from '@/components/common/TypeIcon';
+import { useCountryNames, useLocale, useMessages } from '@/components/hooks';
+import { ListTable } from '@/components/metrics/ListTable';
+
+export function RealtimeCountries({ data }) {
+ const { formatMessage, labels } = useMessages();
+ const { locale } = useLocale();
+ const { countryNames } = useCountryNames(locale);
+
+ const renderCountryName = useCallback(
+ ({ label: code }) => (
+ <IconLabel icon={<TypeIcon type="country" value={code} />} label={countryNames[code]} />
+ ),
+ [countryNames, locale],
+ );
+
+ return (
+ <ListTable
+ title={formatMessage(labels.countries)}
+ metric={formatMessage(labels.visitors)}
+ data={data.map(({ x, y, z }: { x: string; y: number; z: number }) => ({
+ label: x,
+ count: y,
+ percent: z,
+ }))}
+ renderLabel={renderCountryName}
+ />
+ );
+}